<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head> 
<title>Scuola Media E. d'Arborea - Lamarmora </title> 
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
<meta name="description" content="Il sito della scuola secondaria superiore di Iglesias, in Sardegna" /> 
<meta name="keywords" content="scuola, iglesias, didattica, insegnamento, docenti" /> 
<link rel="stylesheet" href="andreas08.css" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="/css/skins/aqua/theme.css" type="text/css" />
<?php include $_ENV["DOCUMENT_ROOT"]."/js/prototype.php" ?>
<script type="text/javascript" src="../../../js/page.js"></script>
<script type="text/javascript" src="/js/calendar.js"></script>
<script type="text/javascript" src="/js/lang/calendar-it.js"></script>
<script type="text/javascript" src="/js/calendar-setup.js"></script>
<script>
function save_homework(){
	//alert($('myform').serialize());
	if(document.forms[0].del.value == 1){
		if(!confirm("Sei sicuro di voler cancellare questo compito?"))
			return false;
	}
	var req = new Ajax.Request('save_homework.php',
			  {
			    	method:'post',
			    	parameters: $('myform').serialize(),
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		var dati = response.split("#");
			     		alert(dati[1]);
			     		window.opener.location.href = "elenco_compiti.php";
			     		window.close();
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore...") }
			  });
}

var oldLink = null;
</script>
</head> 
 
<body> 
<div style="width: 95%; margin: auto; text-align: center; ">
<p style="text-align: center; padding-top: 20px; font-weight: bold"><?php print $title ?></p>
<form id="myform">
<table style="text-align: left; width: 95%;" id="att">
<tr>
	<td style="width: 100px">Per il</td>
	<td>
		<input id="sel3" type="text" value="<?php if($upd == 1) print format_date($di, SQL_DATE_STYLE, IT_DATE_STYLE, "/") ?>" style="width: 249px; border: 1px solid #c0c0c0; font-size: 11px; padding-top: 3px" name="data_inizio" />&nbsp;
		<script type="text/javascript">
            Calendar.setup({
                date		: new Date(),
				inputField	: "sel3",
				ifFormat	: "%d/%m/%Y",
				showsTime	: false,
				firstDay	: 1,
				timeFormat	: "24",
				dateStatusFunc :    function (date) {
            	    return (date.getDay() == 0) ? true : false;
				}
			});
        </script>
	</td>
</tr>
<tr>
	<td style="width: 100px">Materia</td>
	<td>
		<select name="materia" id="tipo" style="border: 1px solid #c0c0c0; font-size: 11px; width: 250px">
			<option value="0">Nessuna</option>
<?php 
while($mat = $res_materie->fetch_assoc()){
?>
			<option <?php if($mat['id_materia'] == $att['materia']) print("selected='selected'") ?> value="<?php print $mat['id_materia'] ?>"><?php print $mat['materia'] ?></option>
<?php 
}
?>
		</select>
	</td>
</tr>
<tr>
	<td style="width: 100px">Dettagli</td>
	<td>
		<textarea style="width: 250px; height: 40px; border: 1px solid #c0c0c0; font-size: 11px" name="descrizione"><?php if($upd == 1) print $att['descrizione'] ?></textarea>
	</td>
</tr>
<tr>
	<td style="width: 100px">Note</td>
	<td>
		<textarea style="width: 250px; height: 40px; border: 1px solid #c0c0c0; font-size: 11px" name="note"><?php if($upd == 1) print $att['note'] ?></textarea>
		<input type="hidden" name="id_act" />
		<input type="hidden" name="del" />
	</td>
</tr>
</table>
</form>
</div>
<div style="width: 92%; text-align: right; margin-top: 20px">
<input type="button" onclick="document.forms[0].id_act.value=<?php print $t ?>; save_homework()" value="Invia" style="border: 1px solid #c0c0c0; width: 50px; font-size: 11px; padding: 2px" id="invia" />&nbsp;&nbsp;&nbsp;
<?php if($t != 0){ ?>
<input type="button" onclick="document.forms[0].id_act.value=<?php print $t ?>; document.forms[0].del.value = 1; save_homework()" value="Elimina" style="border: 1px solid #c0c0c0; width: 50px; font-size: 11px; padding: 2px" id="elimina" />&nbsp;&nbsp;&nbsp;
<?php } ?>
<input type="button" value="Chiudi" style="border: 1px solid #c0c0c0; width: 50px; font-size: 11px; padding: 2px" onclick="window.close()" />
</div>
</body> 
</html>